﻿using System;

class PrintMatrixC
{
    static void Main()
    {
        //int[,] array = 
        //{
        //    { 1, 5, 9, 13 },
        //    { 2, 6, 10, 14 },
        //    { 3, 7, 11, 15 },
        //    { 1, 5, 9, 13 },
        //    { 4, 8, 12, 16 },
        //};
        int n = 4;
        int[,] array = new int[n, n];
        Fill(array,n);
        Print(array);
    }

    static void Fill(int[,] array, int n)
    {
        int counter = 1;

        for (int i = 0; i <= n - 1; i++)
        {
            for (int j = 0; j <= i; j++)
            {
                array[n - i + j - 1, j] = counter;
                counter++;
            }
        }

        for (int i = n - 2; i >= 0; i--)
        {
            for (int j = i; j >= 0; j--)
            {
                array[i - j, n - j - 1] = counter;
                counter++;
            }
        }
    }

    static void Print(int[,] array)
    {
        Console.WriteLine();
        for (int i = 0; i < array.GetLength(0); i++)
        {
            for (int j = 0; j < array.GetLength(1); j++)
            {
                Console.Write(" " + array[i, j]);
            }
            Console.WriteLine();
        }
    }
}